package com.aspose.cells.b.a.b;

import com.aspose.cells.a.d.zfs;
import java.awt.Font;
import java.awt.font.TextAttribute;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

public class zg implements Cloneable {
   private int a;
   private zh b;
   private Font c;
   private byte d;
   private static final float[] e = new float[]{1.0F, 1.0F, 1.0F, (float)zi.c(), (float)zi.c(), (float)zi.c(), (float)zi.c()};
   private final String f;

   public Font a() {
      return this.c;
   }

   public zg(zh var1, float var2) {
      this((zh)var1, var2, 0, 3, (byte)1, false);
   }

   public zg(zh var1, float var2, int var3) {
      this((zh)var1, var2, var3, 3, (byte)1, false);
   }

   public zg(zh var1, float var2, int var3, int var4) {
      this((zh)var1, var2, var3, var4, (byte)1, false);
   }

   public zg(String var1, float var2) {
      this((String)var1, var2, 0, 3, (byte)0, false);
   }

   public zg(String var1, float var2, int var3) {
      this((String)var1, var2, var3, 3, (byte)0, false);
   }

   public zg(String var1, float var2, int var3, int var4) {
      this((String)var1, var2, var3, var4, (byte)0, false);
   }

   public zg(String var1, float var2, int var3, int var4, byte var5, boolean var6) {
      this.a = 3;
      this.f = null;
      if (var1 != null && var1.length() != 0) {
         this.a = var4;
         this.d = var5;
         float var7 = var2 * zi.a()[this.a];

         try {
            new zfs(false);
            this.c = zfs.a(var1, var3, var7, false);
            this.b = new zh(var1, this.c);
         } catch (Exception var10) {
            com.aspose.cells.a.c.zl.b(var10);
            Hashtable var9 = new Hashtable();
            var9.put(TextAttribute.FAMILY, var1);
            var9.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
            var9.put(TextAttribute.SIZE, new Float(var7));
            a(var9, var3, false);
            this.b = a(var1);
            if (this.b == null || this.b.c() == null) {
               throw new IllegalArgumentException("Cannot find required font defination[Family:" + var1 + "]. Please specify correct font path.");
            }

            this.c = this.b.c().deriveFont(var9);
         }

      } else {
         throw new IllegalArgumentException("family");
      }
   }

   public zg(zh var1, float var2, int var3, int var4, byte var5, boolean var6) {
      this.a = 3;
      this.f = null;
      if (var1 == null) {
         throw new IllegalArgumentException("family");
      } else {
         this.a = var4;
         this.b = var1;
         this.d = var5;
         float var7 = var2 * zi.a()[this.a];

         try {
            new zfs(false);
            this.c = zfs.a(var1.b(), var3, var7, false);
         } catch (Exception var10) {
            com.aspose.cells.a.c.zl.b(var10);
            Hashtable var9 = new Hashtable();
            var9.put(TextAttribute.FAMILY, var1.b());
            var9.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
            var9.put(TextAttribute.SIZE, new Float(var7));
            a(var9, var3, false);
            if (var1.c() == null) {
               throw new IllegalArgumentException("Cannot find required font defination by Family[" + var1.b() + "]. Please specify correct font path.");
            }

            this.c = var1.c().deriveFont(var9);
         }

      }
   }

   private static zh a(String var0) {
      try {
         return new zh(var0);
      } catch (Exception var2) {
         return zh.a();
      }
   }

   public boolean equals(Object obj) {
      zg var2 = null;
      var2 = obj instanceof zg ? (zg)obj : null;
      return var2 == null ? false : this.a().equals(var2.a());
   }

   public int hashCode() {
      return this.a().hashCode();
   }

   public final zh b() {
      return this.b;
   }

   public boolean c() {
      return this.c.isBold();
   }

   public int d() {
      return zh.a.getFontMetrics(this.a()).getHeight();
   }

   public float e() {
      return this.a((float)zi.c());
   }

   public float a(float var1) {
      float var2 = (float)this.b.f(this.k()) * (this.i() / (float)this.b.e(this.k())) / 72.0F;
      return var2 * var1;
   }

   public boolean f() {
      return this.c.isItalic();
   }

   public String g() {
      return this.c.getFamily();
   }

   public float h() {
      return this.c.getSize2D() / zi.a()[this.a];
   }

   public float i() {
      return this.c.getSize2D() / zi.a()[this.a];
   }

   public boolean j() {
      try {
         if ((Boolean)this.c.getAttributes().get(TextAttribute.STRIKETHROUGH) == TextAttribute.STRIKETHROUGH_ON) {
            return true;
         }
      } catch (Exception var2) {
         ;
      }

      return false;
   }

   public int k() {
      int var1 = 0;
      if (this.c()) {
         var1 |= 1;
      }

      if (this.f()) {
         var1 |= 2;
      }

      if (this.l()) {
         var1 |= 4;
      }

      if (this.j()) {
         var1 |= 8;
      }

      return var1;
   }

   public boolean l() {
      try {
         if ((Integer)this.c.getAttributes().get(TextAttribute.UNDERLINE) == TextAttribute.UNDERLINE_ON) {
            return true;
         }
      } catch (Exception var2) {
         ;
      }

      return false;
   }

   public int m() {
      return this.a;
   }

   public String toString() {
      return "[Font: Name=" + this.g() + ", Size=" + this.h() + ", Style=" + this.k() + ", Units=" + this.m() + "]";
   }

   public void n() {
   }

   public static Map a(Map var0, int var1, boolean var2) {
      Object var3;
      if (var2) {
         var3 = new Hashtable(var0.size());
         Iterator var4 = var0.keySet().iterator();

         while(var4.hasNext()) {
            Object var5 = var4.next();
            Object var6 = var0.get(var5);
            if (var6 != null) {
               ((Map)var3).put(var5, var6);
            }
         }
      } else {
         var3 = var0;
      }

      if ((var1 & 1) == 1) {
         ((Map)var3).put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
      } else {
         ((Map)var3).remove(TextAttribute.WEIGHT);
      }

      if ((var1 & 2) == 2) {
         ((Map)var3).put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
      } else {
         ((Map)var3).put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
      }

      if ((var1 & 4) == 4) {
         ((Map)var3).put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
      } else {
         ((Map)var3).remove(TextAttribute.UNDERLINE);
      }

      if ((var1 & 8) == 8) {
         ((Map)var3).put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
      } else {
         ((Map)var3).remove(TextAttribute.STRIKETHROUGH);
      }

      return (Map)var3;
   }
}
